package br.ita.escolaita.model.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

@Entity
@Table(name="AVALIACAO")
public class Avaliacao implements Serializable{

    @Transient
    private static final long serialVersionUID = -5816856326514604337L;

    @Id
    @GeneratedValue(strategy=GenerationType.AUTO)
    @Column
    private Integer id;

    @Column
    @Temporal(TemporalType.DATE)    
    private Date dataAvaliacao;

    @Column
    private double nota;

    @ManyToOne
    private Disciplina disciplina;

    @ManyToOne
    private Aluno aluno;

    // Construtor Default
    public Avaliacao(){
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getDataAvaliacao() {
        return dataAvaliacao;
    }

    public void setDataAvaliacao(Date dataAvaliacao) {
        this.dataAvaliacao = dataAvaliacao;
    }

    public double getNota() {
        return nota;
    }

    public void setNota(double nota) {
        this.nota = nota;
    }

    public Disciplina getDisciplina() {
        return disciplina;
    }

    public void setDisciplina(Disciplina disciplina) {
        this.disciplina = disciplina;
    }

    public Aluno getAluno() {
        return aluno;
    }

    public void setAluno(Aluno aluno) {
        this.aluno = aluno;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Avaliacao other = (Avaliacao) obj;
        if (this.dataAvaliacao != other.dataAvaliacao && (this.dataAvaliacao == null || !this.dataAvaliacao.equals(other.dataAvaliacao))) {
            return false;
        }
        if (this.nota != other.nota) {
            return false;
        }
        if (this.disciplina != other.disciplina && (this.disciplina == null || !this.disciplina.equals(other.disciplina))) {
            return false;
        }
        if (this.aluno != other.aluno && (this.aluno == null || !this.aluno.equals(other.aluno))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 37 * hash + (this.dataAvaliacao != null ? this.dataAvaliacao.hashCode() : 0);
        hash = 37 * hash + (int) (Double.doubleToLongBits(this.nota) ^ (Double.doubleToLongBits(this.nota) >>> 32));
        hash = 37 * hash + (this.disciplina != null ? this.disciplina.hashCode() : 0);
        hash = 37 * hash + (this.aluno != null ? this.aluno.hashCode() : 0);
        return hash;
    }
}
 
